package edu.ecnu.yt.spring.di.profile;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
/**
 * 运行时根据Profile决定当前环境需要加载哪个bean。如果bean没有声明profile，
 * 它将被默认加载。
 * @author yutian
 */
@Configuration
public class ProfileConfig {

	@Bean(name="testBean")
	@Profile("dev")
	public TestBean testBeanDev() {
		return new TestBean("Develop");
	}

	@Bean(name="testBean")
	@Profile("product")
	public TestBean testBeanProduct() {
		return new TestBean("Production");
	}
	
	@Bean(name="defaultBean")
	public TestBean defaultBean() {
		return new TestBean("default");
	}
	
}
